package entities;

import java.util.List;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;

public abstract class Enemy extends Entity {
	
	protected boolean destroyOffScreenX;
	protected boolean destroyOffScreenY;
	protected List<Sound> explosionSounds;
	protected int damage;

	public Enemy(String imagePath) throws SlickException {
		super(imagePath);
		damage = 1;
		destroyOffScreenX = true;
		destroyOffScreenY = true;
	}
	
	@Override
	public void checkEntityPosition(GameContainer gc) {
		if (pos.getX() > gc.getWidth() || pos.getX() < 0 - getImage().getWidth()) {
			if (destroyOffScreenX == true) {
				System.out.println("remove");
				level.removeEntity(this);
			}
		}
		if (pos.getY() > gc.getHeight() || pos.getY() < 0 - getImage().getHeight()) {
			if (destroyOffScreenY == true) {
				System.out.println("remove");
				level.removeEntity(this);
			}
		}
	}

	@Override
	public void update(GameContainer gc, int delta) {
		super.update(gc, delta);
		for (Entity e : level.getCollisions(this)) {
			if (e == level.getPlayer()) {
				e.takeDamage(damage);
			} 
		}
	}
}
